package cn.edu.lingnan.config;

import cn.edu.lingnan.Interceptor.RegisterInterceptor;
import cn.edu.lingnan.Interceptor.WebInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private WebInterceptor webInterceptor;
    //.excludePathPatterns("/admin/contestinfo/export")
    @Autowired
    private RegisterInterceptor registerInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // TODO: 2023/4/14 拦截这个路径的信息
        registry.addInterceptor(webInterceptor).excludePathPatterns("/Users/login")
                .excludePathPatterns("/Users/register")
                .excludePathPatterns("/doc.html")
                .excludePathPatterns("/webjars/**")
                .addPathPatterns("/**");

        registry.addInterceptor(registerInterceptor).addPathPatterns("/Users/register");
    }
}
